package com.elbis.access.wg.api.request.account;

import java.util.Iterator;
import java.util.List;

import com.elbis.access.wg.api.request.WOTRequestEntity;

public class AchievementData extends WOTRequestEntity {

	private static final long serialVersionUID = 5949838664243629109L;

	private String language = null;

	private String fields = null;

	private List<Long> account_id = null;

	public AchievementData(String applicationId, List<Long> accounts) {
		super(applicationId);
		account_id = accounts;
	}

	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	public String getFields() {
		return fields;
	}

	public void setFields(String fields) {
		this.fields = fields;
	}

	public List<Long> getAccount_id() {
		return account_id;
	}

	public void setAccount_id(List<Long> account_id) {
		this.account_id = account_id;
	}

	@Override
	public String toHttpRequestParameters() {
		StringBuilder builder = new StringBuilder();
		builder.append(super.toHttpRequestParameters());

		if (language != null) {
			builder.append("&");
			builder.append("language=");
			builder.append(language);
		}
		if (fields != null) {
			builder.append("&");
			builder.append("fields=");
			builder.append(fields);
		}
		if (account_id != null) {
			builder.append("&");
			builder.append("account_id=");
			Iterator<Long> accountIterator = account_id.iterator();
			while (accountIterator.hasNext()) {
				Long id = accountIterator.next();
				builder.append(id);
				if (accountIterator.hasNext()) {
					builder.append(',');
				}
			}
		}

		return builder.toString();
	}

}
